home *** CD-ROM | disk | FTP | other *** search
- Path: gabi-soft.fr!not-for-mail
- From: kanze@gabi-soft.fr (J. Kanze)
- Newsgroups: comp.std.c
- Subject: Re: Faster FILE subroutines in standard C?
- Date: 5 Jan 1996 13:05:55 +0100
- Organization: GABI Software, Sarl.
- Message-ID: <4cj473$n0m@gabi.gabi-soft.fr>
- References: <4cfm7c$dot@sunburst.ccs.yorku.ca>
- NNTP-Posting-Host: gabi.gabi-soft.fr
- X-Newsreader: TIN [version 1.2 PL2]
-
- Kenneth Kafieh (ken@yorku.ca) wrote:
-
- |> I found that I was able to get 3-4 time faster performance by using good
- |> old ANSI C file accessing routines (like fgets, fseek, ftell, ...etc.)
- |> instead of C++ streams (like ifstream::getline, fstream::seekg, ...etc.)
- |> I wrote the program originally in C++ (a simple little phonebook for my
- |> own use) and it took about 9 seconds to scan a 100Kb file for a 3 byte
- |> string!!! Fed up, I rewrote it in C and voila! Now it takes 2 secs!
- |> I'm using Borland C++ v2.0.
-
- |> Does that sound right? Maybe my code was inefficiently written?
- |> I know C++ is generally slower than C but I didn't think that
- |> file stuff would be too. What did I do wrong? Am I missing
- |> something. Maybe I'll post the code too, later. Has anyone
- |> else noticed this too?
-
- This depends on the implementation. With g++ 2.7.2 (libg++ 2.7.1), for
- example, formatted output with iostream is more than twice as fast as
- using fprintf.
-
- |> Come to think of it, the coding in
- |> C was cleaner looking, too.
-
- And more error prone (putting on my abestos suit).
-
- More to the point: I'm currently reading this in comp.std.c, so I would
- guess that iostream is irrelevant, off-topic, and doesn't necessarily
- interest all of the readers. In C, you don't have the choice. (The
- same article was posted to comp.lang.c++.moderated, where it is
- relevant. I would suggest that anyone wishing to follow up to this
- posting do so there.)
- --
- James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
- GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
- Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
- -- A la recherche d'une activitΘ dans une region francophone
-